package com.huike.web.controller.clues;

import com.github.pagehelper.Page;
import com.huike.clues.domain.mpVO.MPTbActivityVO;
import com.huike.clues.domain.vo.MPTableDataInfoActivityListVo;
import com.huike.clues.service.MpActivityService;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.entity.MPSysDictType;
import com.huike.common.entity.MPTbActivity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description TODO
 * @Author 何俊杰
 * @Date 2023-08-29 8:45
 */
@Api(tags = "活动管理相关接口")
@RestController
@RequestMapping("/clues/activity")
@Slf4j
public class MpActivityController {

    @Resource
    private MpActivityService activityService;

    /**
     * 获取状态为2的渠道活动列表
     * @param channel
     * @return
     */
    @GetMapping("/listselect/{channel}")
    @ApiOperation("获取状态为2的渠道活动列表")
    public AjaxResult listselect(String channel){
        List<MPTbActivityVO> mpTbActivityVO = activityService.listselect(channel);
        return AjaxResult.success(mpTbActivityVO);
    }


    /**
     * 获取活动管理详情信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("获取活动管理详情信息")
    public AjaxResult findId(@PathVariable Integer id){
        MPTbActivity mpTbActivity = activityService.findId(id);
        return AjaxResult.success(mpTbActivity);
    }

    /**
     * 修改活动管理
     * @param mpTbActivity
     * @return
     */
    @PutMapping
    @ApiOperation("修改活动管理")
    public AjaxResult update1(@RequestBody MPTbActivity mpTbActivity){
        activityService.update1(mpTbActivity);
        return AjaxResult.success();
    }

    /**
     * 删除活动管理
     * @return
     */
    @DeleteMapping("/{ids}")
    @ApiOperation("删除活动管理")
    public AjaxResult delete(@PathVariable List<String> ids){
        activityService.delete(ids);
        return AjaxResult.success();
    }

    /**
     * 查询活动管理列表
     * @param tbActivity
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询活动管理列表")
    public TableDataInfo actibityList(MPTbActivity tbActivity){
        Page<MPTbActivity> mpSysDictTypes = activityService.actibityList(tbActivity);
        TableDataInfo objectTableDataInfo = new TableDataInfo();
        objectTableDataInfo.setTotal(mpSysDictTypes.getTotal());
        objectTableDataInfo.setRows(mpSysDictTypes.getResult());
        objectTableDataInfo.setCode(200);

        return objectTableDataInfo;



       /* MPTableDataInfoActivityListVo tab = activityService.actibityList(tbActivity,pageNum,pageSize);
        tab.setCode(200);
        tab.setMsg("查询成功");
        return tab;*/
    }

    /**
     * 新增活动管理
     * @return
     */
    @PostMapping
    @ApiOperation("新增活动管理")
    public AjaxResult add(@RequestBody MPTbActivity tbActivity){
        activityService.add(tbActivity);
        return AjaxResult.success();
    }

}
